package com.abc.robot01.flutter


import android.os.Bundle
import androidx.annotation.NonNull
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugins.GeneratedPluginRegistrant

const val CHANNEL: String = "com.abc.robot01.flutter.qa"

class QaActivity: FlutterActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }

    override fun getInitialRoute(): String {
        // 指定加载的 Flutter 界面
        return "/qa2"
    }

    override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine)
        MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL)
            .setMethodCallHandler { call, result ->
                if (call.method!!.contentEquals("get_all_maps")) {
                    result.success("1_2_3_4")
                    return@setMethodCallHandler
                }
                if (call.method!!.contentEquals("get_points")) {
                    val mapName = call.argument<String>("name")
                    result.success("前台${mapName}_办公室${mapName}_办公室${mapName}")
                    return@setMethodCallHandler
                }
            }
    }
}
